#include "GY_PenWidth.h"
#include "QDebug"

GY_PenWidth::GY_PenWidth(QWidget* parent)
    :QLabel(parent)
{

}

GY_PenWidth::~GY_PenWidth()
{

}

void GY_PenWidth::setDrawParameters(int drawType, int size)
{
    m_drawType = drawType;
    m_size = size;
}

void GY_PenWidth::paintEvent(QPaintEvent *)
{
    QSize size = this->size();
    QPainter painter(this);
    QPen pen;
    pen.setColor(Qt::black);
    pen.setWidth(m_size);
    painter.setPen(pen);
    if(m_drawType==0) //如果是画点
    {
        painter.drawPoint(QPoint(size.width()/2,size.height()/2));
    }
    else //如果是画线
    {
        QPoint point1(0,size.height()/2);
        QPoint point2(size.width(),size.height()/2);
        QLine line(point1,point2);
        painter.drawLine(line);
    }
}
